import java.lang.System;
import java.util.HashMap;
import java.util.Map;
import java.lang.String;

/**
 * 盛最多水的容器
 */
public class LargestContainer {

    public int solution(int[] height) {
        int left = 0, right = height.length -1;
        int max = 0;
        while (left < right) {
            int cur = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(max, cur);
            if (height[left] < height[right]) {
                left ++;
            } else {
                right --;
            }
        }
        return max;
    }

    public static void main(String[] args) {
        int[] data = new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7};
        int result = new LargestContainer().solution(data);
        System.out.print("result: " + result);
    }
}
